package cn.yuemouren.queue;

import cn.yuemouren.heap.maxheap.MaxHeap;

/**
 * @Author: Timi
 * @Description: 优先队列(用最大堆实现)
 * @Date: 2020/7/2 8:56
 */
public class PriorityQueue<T extends Comparable<T>> implements Queue<T>{

    private MaxHeap<T> heap;

    public PriorityQueue() {
        this.heap = new MaxHeap<>();
    }

    @Override
    public void enQueue(T t) {
        heap.add(t);
    }

    @Override
    public T dnQueue() {
        return heap.extractMax();
    }

    @Override
    public T getHead() {
        return heap.getMax();
    }

    @Override
    public int getSize() {
        return heap.getSize();
    }

    @Override
    public boolean isEmpty() {
        return heap.isEmpty();
    }
}
